package org.com.app.knock.activity;

import org.com.app.knock.KnockApplication;
import org.com.app.knock.fragment.SplashFragment;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;

import com.acv.libs.nbase.MBaseActivity;
import com.app.knock.db.Account;
import com.knock.app.R;

public class SplashActivity extends MBaseActivity {
	public static int height;
	public static int width;
	private Handler handler = new Handler() {
		@Override
		public void dispatchMessage(Message msg) {
			super.dispatchMessage(msg);
			if (!isFinishing()) {
				startActivity(new Intent(SplashActivity.this, UerMainActivity.class));
				finish();
				overridePendingTransition(R.anim.a_bot_to_top_in,R.anim.a_nothing);
			}
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		overridePendingTransition(R.anim.a_bot_to_top_in,R.anim.a_nothing);
		KnockApplication.tracker.trackPageView("/HomeScreen");
		setContentView(R.layout.mainhome);
		String token =  new Account(this).getToken();
		if(!"".equals(token) && !"null".equals(token)){
			Intent Page = new Intent(this, FriendActivity.class);
			startActivityForResult(Page,0); 
		}else{
			SplashFragment fragment = new SplashFragment();
			fragment.mHandle = handler;
			changeFragemt(R.id.mainhomeframe, fragment);
		}
		
		
		DisplayMetrics metrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(metrics);
		height = metrics.heightPixels;
		width = metrics.widthPixels;
		
	}

	@Override
	public void onBackPressed() {
		return;
	}

}